package com.sure.supermarketserver.stock.manage;

import com.sure.supermarketserver.common.CommonService;
import com.sure.supermarketserver.common.Result;
import com.sure.supermarketserver.stock.supplier.SupplierDto;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/stock/manage")
public class GoodsAPI {

    @Resource
    private GoodsService goodsService;

    @Resource
    private CommonService commonService;

    @GetMapping("")
    public Result goodsList(GoodsDto goodsDto){
        Map<String,Object> page = goodsService.findGoodsList(goodsDto);
        return Result.success(page);
    }


    @GetMapping("/details")
    public Result goodsDetails(GoodsDto goodsDto){
        Map<String,Object> page = goodsService.findGoodsDetails(goodsDto);
        return Result.success(page);
    }

    @PutMapping("{id}")
    public Result supplierUpd(@PathVariable String id) {
        goodsService.execGoods(id);
        return Result.success();
    }

    @PutMapping("")
    public Result goodsUpd(@RequestBody GoodsDto dto) {
        goodsService.updGoods(dto);
        return Result.success();
    }

    @GetMapping("/branch")
    public Result branchList(){
        List<BranchName> branchList=goodsService.findBranchList();
        return Result.success(branchList);
    }


}
